# -*- coding: utf-8 -*-
# @Time    : 2021/4/3 22:33
# @Author  : Zhangrenjie
# @Email   : zhangrenjie1998@163.com
# @File    : passwd_verify.py
# @Software: PyCharm

def length_check(passwd):
    if len(passwd) < 8:
        return 0
    else:
        return 1


def complex_check(passwd):
    result = {'upper': 0, 'lower': 0, 'digit': 0, 'char': 0}
    for item in passwd:
        if sum(result.values()) >= 3:
            break
        else:
            if item.isdigit():
                result['digit'] = 1
            elif item.isupper():
                result['upper'] = 1
            elif item.islower():
                result['lower'] = 1
            else:
                result['char'] = 1
    if sum(result.values()) >= 3:
        return 1
    else:
        return 0


def str_count_check(passwd: str):
    for i in range(len(passwd)):
        if i+3 <= len(passwd):
            st = passwd[i:i+3]
            print(st)
            num = passwd.count(st)
            print(num)
            if num >= 2:
                return 0
    return 1


def decide(length, complex, count):
    info = []
    if length == 0:
        info.append("长度小于8")
    if complex == 0:
        info.append("密码没有有3种以上字符组成")
    if count == 0:
        info.append("不能有长度超过或者等于3的字串重复")
    level = length+count+complex+2
    if level == 5:
        return level
    else:
        return level, info


passwd_input = input("请输入需检查的密码：")
# 查看
grade1 = length_check(passwd_input)
grade2 = complex_check(passwd_input)
grade3 = str_count_check(passwd_input)
lst = decide(grade1, grade2, grade3)
print(lst)


